package com.gtw.modules.sys.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.gtw.modules.sys.service.SysCommodityPropertyService;
import com.gtw.modules.dao.TbCommodityPropertyDao;
import com.gtw.modules.entity.TbCommodityProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;


@Service("SysCommodityPropertyservice")
public class SysCommodityPropertyServiceImpl implements SysCommodityPropertyService {
    @Autowired
    private TbCommodityPropertyDao commodityPropertyDao;


    @Override
    public Page<TbCommodityProperty> queryPageList(Page<TbCommodityProperty> page, Map<String, Object> map) {
        page.setRecords(commodityPropertyDao.queryPageList(page, map));
        return page;
    }

    @Override
    public TbCommodityProperty queryObject(Integer id) {
        return commodityPropertyDao.selectByPrimaryKey(id);
    }

    @Override
    public void save(TbCommodityProperty commodityProperty) {
        commodityPropertyDao.insert(commodityProperty);
    }

    @Override
    public void update(TbCommodityProperty commodityProperty) {
        commodityPropertyDao.updateByPrimaryKey(commodityProperty);
    }

    @Override
    public void delete(Integer id) {
        TbCommodityProperty tcp = commodityPropertyDao.selectByPrimaryKey(id);
        tcp.setIsdelete(true);
        commodityPropertyDao.updateByPrimaryKey(tcp);
    }

    @Override
    public void deleteBatch(Integer[] ids) {
        for (int i = 0; i < ids.length; i++) {
            TbCommodityProperty tcp = commodityPropertyDao.selectByPrimaryKey(ids[i]);
            tcp.setIsdelete(true);
            commodityPropertyDao.updateByPrimaryKey(tcp);
        }
    }

}
